<?php

abstract class Admin_Page_Abstract extends ME_Abstract_Page
{
	/**
	* @var ME_DAL_RefreshCacheLoader
	*/
	protected static $_cache;
	
	protected static $_dbGameData;
	
	protected function _loadDb()
	{
	}
    
	public function __construct(ME_Request $input, ME_Response $output)
	{
		$this->_loadDb();

		$output->execName =
		$input->execName  = $input->getExecName();
		
		$output->actName  =
		$input->actName   = $input->getActionName();
		
		$output->ctlName  =
		$input->ctlName   = $input->getControllerName();
	}
	
	/**
	* 初始化缓存
	*/
	public static function init()
	{
		self::$_cache = ME_DAL_RefreshCacheLoader::getInstance();
	}
	
	/**
	* 加载缓存
	* @return array DAL data
	*/
	protected static function loadCache($moduleName, $param = array(), $num = 0)
	{
		self::init();
		$data = self::$_cache->loadCacheObject($moduleName, $param);

		if ($num && $data && count($data) > $num) {
			$data = array_slice($data, 0, $num, true);
		}

		return $data;
	}
	
	/**
	* 更新缓存
	* 
	* @param string $moduleName
	* @param array  $param
	* @return boolean
	*/
	protected static function refreshCache($moduleName, $param = array())
	{
		self::init();
		return self::$_cache->refreshCacheObject($moduleName, $param);
	}
}
